//
//  ChooseLineViewController.m
//  DA_V
//
//  Created by 周季阳 on 15/5/7.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "ChooseLineViewController.h"
#import "InterFace.h"
#import "UIViewAdditions.h"
#import "RecommendNewViewController.h"
@interface ChooseLineViewController ()

@end

@implementation ChooseLineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBarHidden=YES;
    
    self.view.backgroundColor = [self colorWithHexString:@"#F5F5F5"];
    [self initNav];
    navTitle.text = @"推荐新微商";
    
    [self initUI];
    
}
#pragma mark - initUI
-(void)initUI{
    UIView *backgroundView = [[UIView alloc]initWithFrame:CGRectMake(0, navView.bottom, SCREEN_WIDTH, 220)];
    backgroundView.backgroundColor = [UIColor whiteColor];
    backgroundView.userInteractionEnabled = YES;
    [self.view addSubview:backgroundView];
    
    UILabel *chooseLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 300, 30)];
    chooseLabel.text = @"选择添加下线的等级";
    chooseLabel.font = [UIFont systemFontOfSize:16];
    chooseLabel.textColor = [UIColor blackColor];
    chooseLabel.textAlignment = NSTextAlignmentLeft;
    [backgroundView addSubview:chooseLabel];
    
    //1级
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn1.frame = CGRectMake(10, chooseLabel.bottom+10, SCREEN_WIDTH-20, 38);
    btn1.tag = 300;
    [btn1 setBackgroundImage:[UIImage imageNamed:@"选择下线等级_03"] forState:UIControlStateNormal];
    [btn1 addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    [backgroundView addSubview:btn1];
    
    //2级
    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn2.frame = CGRectMake(10, btn1.bottom+10, SCREEN_WIDTH-20, 38);
    btn2.tag = 301;
    [btn2 setBackgroundImage:[UIImage imageNamed:@"选择下线等级_06"] forState:UIControlStateNormal];
    [btn2 addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    [backgroundView addSubview:btn2];
    
    //特约
    UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn3.frame = CGRectMake(10, btn2.bottom+10, SCREEN_WIDTH-20, 38);
    btn3.tag = 302;
    [btn3 setBackgroundImage:[UIImage imageNamed:@"选择下线等级_08"] forState:UIControlStateNormal];
    [btn3 addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    [backgroundView addSubview:btn3];
    
    //no
    UIButton *btn4 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn4.tag = 303;
    btn4.frame = CGRectMake(10, chooseLabel.bottom+10, SCREEN_WIDTH-20, 38);
    [btn4 setBackgroundImage:[UIImage imageNamed:@"选择下线等级---4_03"] forState:UIControlStateNormal];
    [btn4 setBackgroundImage:[UIImage imageNamed:@"选择下线等级---4_03"] forState:UIControlStateHighlighted];
    //[btn4 addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    [backgroundView addSubview:btn4];
    
    NSInteger i = [[[NSUserDefaults standardUserDefaults]objectForKey:@"LevelID"] integerValue];
    switch (i) {
        case 2:
            //大v
            btn4.hidden = YES;
            backgroundView.frame = CGRectMake(0, navView.bottom, SCREEN_WIDTH, 220);
            break;
        case 3:
            //1级
            btn4.hidden = YES;
            btn1.hidden = YES;
            btn2.frame = CGRectMake(10, chooseLabel.bottom+10, SCREEN_WIDTH-20, 38);
            btn3.frame = CGRectMake(10, btn2.bottom+10, SCREEN_WIDTH-20, 38);
            backgroundView.frame = CGRectMake(0, navView.bottom, SCREEN_WIDTH, 170);
            break;
        case 4:
            btn4.hidden = YES;
            btn1.hidden = YES;
            btn2.hidden = YES;
            btn3.frame = CGRectMake(10, chooseLabel.bottom+10, SCREEN_WIDTH-20, 38);
            backgroundView.frame = CGRectMake(0, navView.bottom, SCREEN_WIDTH, 120);
            break;
        default:
            //特约
            btn3.hidden = YES;
            btn1.hidden = YES;
            btn2.hidden = YES;
            backgroundView.frame = CGRectMake(0, navView.bottom, SCREEN_WIDTH, 120);
            break;
    }
}
-(void)clickBtn:(UIButton *)sender{
    RecommendNewViewController *recommend = [[RecommendNewViewController alloc]init];
    NSString *levelName ;
    switch (sender.tag-300) {
        case 0:
            levelName = @"3";
            break;
        case 1:
            levelName = @"4";
            break;
        default:
            levelName = @"5";
            break;
    }
    recommend.levelNumber = levelName;
    [self.navigationController pushViewController:recommend animated:YES];
}
#pragma mark - 返回
-(void)clickBackBtn{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
